

<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>网页标题</title>
	  <script src='scripts/jquery.js'></script>
		<style></style>
	</head>
	<body>
		<form action="http://plrabbit.com/Test/details.php">
			<input type="text" placeholder='weather' name='wea' id='weather'>
		</form>
		<h1>温度：<span id='weaContent'></span></h1>
		<h2>city:</h2>
		<h2>cityid:</h2>
		<h2>citycode:</h2>
	</body>
	<script>
			$(document).ready(function(){
				$('#weather').keydown(function(e){
					if(e.keyCode==13){
						$('#weaContent').html('Loading...');
						weather().done(function(data){
							var code=get(data);
								getWeather(code).done(function(data){
								data=data.result;
								$('#weaContent').html(data.templow+'~'+data.temphigh);
								//console.log()
							});
					});
						return false;
					}
			})

			function weather(){
				return $.get('http://plrabbit.com/Test/weather.php');
			}

	function get(data){
		var $city=$('#weather').val(),
			$h2s=$('h2');
			data=data.result;//返回的结果
		for(var i=0,dataLen=data.length;i<dataLen;i++){
			if(data[i].city==$city){
				$h2s.eq(0).html('City:'+data[i].city);
				$h2s.eq(1).html('CityId:'+data[i].cityid);
				$h2s.eq(2).html('CityCode:'+data[i].citycode);
				return data[i].citycode;
			}
		}
	}
	function getWeather(code){
			return $.get('http://plrabbit.com/Test/details.php',{
				citycode:code,
			});
		}
	});
	</script>
	<script>
		/*$.get('http://localhost/0826.php',{
			name:'sr',
		}).done(function(data){
			console.log(data);
		})*/
		var username='admin',
		/*$.post('http://localhost/0826.php',{
			username:username,
			password:'123456',
		}).done(function(data){
			console.log(data);
		}).always(function(status,d){
			console.log(status,d);
		}).fail(function(){
			console.log('request!')
		})*/
		$.ajax({
			headers:{//设置请求头
				apikey:'000000002'
			}
			url:'http://.....',
			type='GET',
			data:{name:'admin'}
		})
	</script>
</html>